/**
 * Created by zhaojiuyang1 on 15/5/4.
 */

var mysql = require("mysql");
var Q = require("q");
var log4js = require('log4js');
//获取该js的log
var log = log4js.getLogger("userHelper");
var connectMysql = function(mysqlOptions){
    var deferred = Q.defer();
    var mysqlConn = mysql.createConnection(mysqlOptions);
    mysqlConn.connect(function(err) {
        if (err) {
            return deferred.reject(err);
        }
        log.info('mysql connected: %s', mysqlOptions.host);
        deferred.resolve(mysqlConn);

    });
    return deferred.promise;
};
exports.connectMysql = connectMysql;







